package com.itheima.sh.config;

/*Mybatisplus分页查询用的类*/


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
//官方必须引入的注解代码
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        //设置请求的页面大于最大页操作，true调回到首页，flase继续请求 默认false
//        paginationInterceptor.setOverflow(flase);

        //设置请求的页面限制数量，默认500条，-1不收限制
//                paginationInterceptor.setLimit(500)
        //开启count的join优化 只针对部分 ；left join
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());

        return interceptor;
    }

}
